package org.yoao.crm.dao;

import java.util.List;
import org.yoao.crm.DBManager.DBManager;

/**
 * @author yxwonline.com
 * @description
 * @date 2010-9-19 下午03:02:21
 */
public class ExportDAO extends DBManager {

	public List findAllById(String id, String tableName) throws Exception {
		String sql = "select * from " + tableName;
		if (id != null && !id.trim().equals(""))
			sql += " where id in(" + id + ")";
		return queryMultiColumn(sql);
	}

	public List findTGUser(String id) throws Exception {
		String sql = "select mmuser.id, mmuser.userName, mmuser.email, mmuser.qq, mmuser.mobile, "
				+ "mmuser.platForm, mmuser.account, mmuser.type, mmuser.createTime, mmuser.amount, "
				+ "mmuser.passWord, mmuser.userCode, mmuser.expandCode, baseuser.nickName as userSno, "
				+ "mmuser.amountTotal, mmuser.amountTotalHistory from mmuser "
				+ "left join baseuser on baseuser.userName=mmuser.userSno ";
		if (id != null && !id.trim().equals(""))
			sql += " where mmuser.id in(" + id + ")";
		return queryMultiColumn(sql);
	}

	public List findTGOrder(String id) throws Exception {
		String sql = "select mmorder.id, product.proName as productName, mmorder.orderNumber, mmorder.subscriber, "
				+ "mmorder.mobile, mmorder.address, mmuser.userName as referral, mmorder.amount, mmorder.status, "
				+ "mmorder.createTime, baseuser.nickName as userSno, mmorder.memo from mmorder "
				+ "left join product on product.id=mmorder.productName "
				+ "left join mmuser on mmuser.expandCode=mmorder.referral "
				+ "left join baseuser on baseuser.userName=mmorder.userSno ";

		if (id != null && !id.trim().equals(""))
			sql += " where mmorder.id in(" + id + ")";
		return queryMultiColumn(sql);
	}
}